using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Dynamic;
using YTS.Tools;

namespace Test.ConsoleProgram.Algorithm.Work
{
    [TestDescription("工作逻辑: 位枚举计算")]
    public class Test_EnumFlags : AbsBaseTestItem
    {
        public override void OnTest()
        {
            Assert.TestExe(EnumHelper.ToEnum, (string)null, Type.B11, Type.B11);
            Assert.TestExe(EnumHelper.ToEnum, "", Type.A, Type.A);
            Assert.TestExe(EnumHelper.ToEnum, "0", Type.Customer, Type.Customer);
            Assert.TestExe(EnumHelper.ToEnum, "1", Type.ALL, Type.ALL);
            Assert.TestExe(EnumHelper.ToEnum, "2", Type.B1, Type.B1);
            Assert.TestExe(EnumHelper.ToEnum, "3", Type.B21, (Type.ALL | Type.B1));
            Assert.TestExe(EnumHelper.ToEnum, "4", Type.B11, Type.B11);
            Assert.TestExe(EnumHelper.ToEnum, "5", Type.ALL, (Type.ALL | Type.B11));
            Assert.TestExe(EnumHelper.ToEnum, "6", Type.ALL, (Type.B1 | Type.B11));
            Assert.TestExe(EnumHelper.ToEnum, "7", Type.ALL, (Type.ALL | Type.B1 | Type.B11));
        }

        [Flags]
        public enum Type
        {
            ALL = 1 << 0, // 1
            B1 = 1 << 1, // 2
            B11 = 1 << 2, // 4
            B2 = 1 << 3, // 8
            B21 = 1 << 4, // 16
            A = 1 << 5, // 32
            Customer = 1 << 6, // 64
        }
    }
}
